<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
    if (window.testRunner)
      testRunner.setPopupBlockingEnabled(false);

    var windowsInThisProcess = 1; // This window counts.

    test(t => {
        var w = window.open("", "", "noopener");
        assert_equals(w, null);
        if (window.testRunner)
            assert_equals(testRunner.windowCount(), windowsInThisProcess, "Should have opened a window in a new process.");
    }, "window.open returns 'null' when 'noopener' present.");

    test(t => {
        var w1 = window.open("", "windowname1", "noopener");
        if (window.testRunner)
            assert_equals(testRunner.windowCount(), windowsInThisProcess, "Should have opened a window in a new process.");
        var w2 = window.open("", "windowname1");
        if (window.testRunner)
            assert_equals(testRunner.windowCount(), ++windowsInThisProcess, "Should have opened a window in this process.");
        assert_equals(w1, null);
        assert_not_equals(w2, null);
    }, "Opening a named window as noopener, then normally should work.");

    test(t => {
        var w1 = window.open("", "windowname2");
        if (window.testRunner)
            assert_equals(testRunner.windowCount(), ++windowsInThisProcess, "Should have opened a window in this process.");
        var w2 = window.open("", "windowname2", "noopener");
        if (window.testRunner)
            assert_equals(testRunner.windowCount(), windowsInThisProcess, "Should have opened a window a new process.");
        assert_not_equals(w1, null);
        assert_equals(w2, null);
    }, "Opening a named window normally, then as noopener should work.");
</script>
